//
//  UIImageView+WebImage.swift
//  WB
//
//  Created by macssss on 16/7/6.
//  Copyright © 2016年 macssss. All rights reserved.


import SDWebImage

//MARK: - 隔离SDW设置图像
extension UIImageView {
    
    func zs_setImage(urlString: String?,  placeholderImage: UIImage?, isAvatar: Bool = false) {
        
        guard let urlString = urlString,
            url = URL(string: urlString)   else {
            
                image = placeholderImage
                return
        }
        
        
        sd_setImage(with: url, placeholderImage: placeholderImage, options: [], progress: nil) { [weak self] (image, _, _, _) in
            
            if isAvatar {
                
                self?.image = image?.zs_avatarImage(size: self?.bounds.size)
            }
            
        }
    }
}


